package server

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

var UserMap map[string]string
var CodeMap map[string]string

func Start() {

	UserMap = make(map[string]string)
	CodeMap = make(map[string]string)

	bindAddress := "localhost:8080"
	r := gin.Default()

	r.GET("/ping", Ping)

	r.LoadHTMLGlob("client/*")
	r.Static("/assets", "./assets")

	//r.LoadHTMLFiles("client/client.tmpl")
	r.GET("/", func(c *gin.Context) {
		c.HTML(http.StatusOK, "client.tmpl", gin.H{
			"title": "Main website",
		})
	})

	r.GET("/login", func(c *gin.Context) {
		c.HTML(http.StatusOK, "login.html", gin.H{
			"title": "login",
		})
	})

	r.POST("/desk", Desk)

	r.GET("/socket", Socket)

	r.Run(bindAddress)

}
